package election.platform;

import election.api.Get;

public class CountdownGet implements Get<Object>
{
    int countdown;
    Get<Object> feed;

    public CountdownGet(Get<Object> feed, int n)
    {
        this.feed = feed;
        this.countdown = n - 1;
    }
    
    @Override
    public Object get() throws Exception
    {
        Object obj = feed.get();
        while (obj == null && countdown > 0) {
            countdown --;
            obj = feed.get();
        }
        return obj;
    }

}
